<%@ page language="java" import="java.util.*,com.hs.core.utils.*,com.hs.core.utils.*,com.hs.auth.model.*,com.hs.auth.*" pageEncoding="utf-8"%>
<%
   String pageStr = (String)request.getAttribute("pagestr");
   List datalist = (List)request.getAttribute("datalist");
   String pagenum = (String)request.getAttribute("pagenum");
   String pagecount = (String)request.getAttribute("pagecount");
   String allfullsql = (String)request.getAttribute("allfullsql");
   
	
   int pagenumInt = Integer.parseInt(pagenum==null?"0":pagenum);
   int pagecountInt = Integer.parseInt(pagecount==null?"0":pagecount);
   String orderName = (String)request.getAttribute("orderName");
   String orderNum = (String)request.getAttribute("orderNum");  
   String datatype = (String)request.getAttribute("datatype");  
   
   String onesql = (String)request.getAttribute("onesql");
   String searchtype = (String)request.getAttribute("searchtype");//基本检索、高级检索
   String issecond = (String)request.getAttribute("issecond"); 
   String tags = (String)request.getAttribute("tags"); 
   String searchstrinfo = (String)request.getAttribute("searchstrinfo"); 
   String keyword = (String)request.getAttribute("keyword"); 
  
   String beforesql = (String)request.getAttribute("beforesql"); 
   String paramstr = (String)request.getAttribute("paramstr"); 
   String onekeyword = (String)request.getAttribute("onekeyword"); 
   String onesearchinfo = (String)request.getAttribute("onesearchinfo"); 
   HsAccount accInfo = (HsAccount)session.getAttribute(AUTHConstant.USERINSESSION); 
    String accid = String.valueOf(accInfo==null?"":accInfo.getId());
   Map continfo = (Map)request.getAttribute("continfo");
   
   Map authMap = (Map)session.getAttribute("USERPOWER_"+accInfo.getId()); 
   if(authMap == null)
	authMap = new HashMap();
 
 boolean role4 = (authMap.get("SCHD_ROLE4")!=null); //题录检索人员
 
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<%@ include file="../../include.jsp"%> 
<script language=JavaScript>

 //题录信息
 function magaInfo(id)
{
	var pageURL = "<%=basePath %>data/magainfo.do?id=" + id;
	openwindow(pageURL,'800','600',''); 
}
//详细数据信息
 function auditInfo(id){
	var pageURL = "<%=basePath %>audit/auditlistFrame.do?id=" + id;
	openwindow(pageURL,'1000','800',''); 
    //window.location.href=pageURL;
 }
 
function exportResult(){
 	var checkObj =  document.all.checkmaga;
 	var magaid = "";
 	for(var i=0 ;i<checkObj.length; i++){
 		if(checkObj[i].checked){
 			magaid = magaid + checkObj[i].value + ",";
 		}
 	} 
 	if(magaid != ""){
 		var allsql = document.all.allsql.value;
 		document.exportform.action="<%=basePath%>search/exportMagaResult.do?magaid="+magaid+"&allsql="+ encodeURIComponent(allsql)+"&resulttype=1";	
  		document.exportform.submit();
 	}else{
 		alert("请选择要导出的数据!");
 	}
}
 
function exportAllResult(){
 	var allsql = document.all.allsql.value;
 	document.exportform.action="<%=basePath%>search/exportMagaResult.do?allsql="+ encodeURIComponent(allsql)+"&resulttype=2";	
  	document.exportform.submit();
 }
 
function orderResult(colname,ordernum){
	var searchtype = document.getElementById('searchtype').value; 
	//var paramstr = searchform.paramstr.value; 
	pageForm.orderName.value = colname;
	pageForm.orderNum.value = ordernum;
	var sql = pageForm.searchSql.value;
	//a.title
	//a.bookname
	//a.bookcd
	//a.PERIODICALNAME
	//a.YEARSTR
	//alert(sql);
	var orderbystr = "";
	var index = sql.indexOf("order by");
	var index1 = sql.lastIndexOf("where");
	var sqlone = sql.substr(sql,index);
	var sqltwo = sql.substr(index1,sql.length); 
	if('1' == ordernum){
		orderbystr += ' order by ' + colname + " asc";
	}else{
		orderbystr += ' order by ' + colname + " desc";
	}
	sql = sqlone + orderbystr+') ' + sqltwo;
	//alert(sql);
	pageForm.searchSql.value = sql; 
    var onestr =  "?orderName="+colname+"&orderNum="+ordernum ;
    pageForm.action = "<%=basePath %>search/dosearch.do"+onestr;
 	pageForm.submit(); 
	/**
	if(searchtype == 'advmod'){ 
		advModSearch(colname,ordernum);
	}else if(searchtype == 'advbook'){
	    advBookSearch(colname,ordernum);
	}else if(searchtype == 'adveng'){
	    advEngSearch(colname,ordernum);
	}  
	*/
}
function exportData()
{
    var papers = getSelectPaper();
    if('' == papers){
    	alert('请选择要导出的文献!');
    	return;
    }
	document.dataform.action="<%=basePath%>search/exportAllData.do?ids="+papers;	
  	document.dataform.submit();
}
function getSelectPaper(){
	var ids = document.getElementsByName("paperid");    
    var idstr = "";          
    for (var i = 0; i < ids.length; i++)               
    {                     
           if(ids[i].checked){
           	 idstr += ids[i].value+",";
           }            
    }     
    return idstr;
}
$(document).ready(function(){
	$("#tipcontain").jTipsShow({
		delaytime:200,
		tipsTag: 'span',
		tipsTitle: 'title'
	}); 
});
function downloadpdf(pid,isimg){ 
	if('0' == isimg){
		alert("该文献尚未上传原文！");
		return;
	}else{
		openwindow('<%=basePath%>data/mod/downloadFile.do?pid='+pid,'0','0','');
	}
}
</script>
<style> 
 
.highlight { 
    background-color:#FF00FF; color:#FF0000;
} 

</style>
</head>
<body>
<!--检索结果-->
<div class="pageWrap tar">
     <input onclick="selectAll(true,'paperid');" type="button" value="全选" class="btn"/>
            <input onclick="selectAll(false,'paperid');" type="button" value="清除" class="btn"/>
            <input onclick="exportData();" type="button" value="导出" class="btn"/>
</div>
<dl class="listWrap">
<% if(null != datalist && datalist.size()>0){
                int counter = 0;
      		    for(int i =0;i<datalist.size();i++){
      			    Map dm = (Map)datalist.get(i);
      			    String type = dm.get("DATATYPE")+"";
      			    boolean oldOrMod = false;
      			    if("3".equals(type)){
      			    	oldOrMod = true;
      			    }
      			    counter++; 
      			    
          %> 
   <form name="dataform" action="<%=basePath %>search/exportAllData.do" method=post>
    <dt><input name="paperid" type="checkbox" value="<%=dm.get("ID") %>" />  
    
    <%
    String title = (String)dm.get("TITLE");
    if(null == title)
       title = "";
       String temp = title.length()>80?title.substring(0,80)+"...":title;
	   out.print("<a  href=javaScript:openwindow(\"");
	   out.print(basePath);
	   out.print("search/viewdetail.do?pid="+ dm.get("ID") );
	   out.print("\",'1024','768',''); style='text-decoration:none;' id=titleinfo title='"+title+"'>");
       out.print(SystemUtil.higiLight(temp,null,keyword));  
       out.print("</a>"); 
    
    %>
         <%if("1".equals(dm.get("ISIMG")+"")&&!role4){ %><a href="javaScript:downloadpdf('<%=dm.get("ID") %>');"><i class="icon_down"></i></a><%}else{%><i class="icon_down"></i> <%}%> 
    
    
    </dt>
    <dd>
                   <%
	                String abstr = StringUtilTool.NULL2Blank((String)dm.get("ABSTRACT"));
	                if(abstr.length()>300){
	                	out.println(SystemUtil.higiLight(abstr.substring(0,300),null,keyword));
	                	out.println("...");
	                } else{
	                	out.println(SystemUtil.higiLight(abstr,null,keyword));
	                }
	                %>       
	                 <p>
        	【作者】<%= SystemUtil.higiLight(StringUtilTool.NULL2Blank((String)dm.get("AUTHOR")),null,keyword)%>&nbsp;&nbsp;【作者单位】<%=SystemUtil.higiLight(StringUtilTool.NULL2Blank((String)dm.get("AUTHORUNIT")),null,keyword)%><br />
        	【期刊】<%= SystemUtil.higiLight(StringUtilTool.NULL2Blank((String)dm.get("PERIODICALNAME")),null,keyword)%><%= StringUtilTool.NULL2Blank((String)dm.get("PERIOD"))%>&nbsp;&nbsp;<br />
        	【主题词】<%= SystemUtil.higiLight(StringUtilTool.NULL2Blank((String)dm.get("SUBJECTWORD")),null,keyword)%><br />
        	【关键词】<%= SystemUtil.higiLight(StringUtilTool.NULL2Blank((String)dm.get("KEYWORD")),null,keyword)%><br />
            &nbsp;<a href="javaScript:openwindow('<%=basePath %>search/viewdetail.do?pid=<%=dm.get("ID")%>','1024','768','');">查看</a>
<%if(!role4){ %><a href="javaScript:downloadpdf('<%=dm.get("ID") %>','<%=dm.get("ISIMG")%>');">下载</a><%} %></p>       
    </dd>
    <%}}else{ %>
    <dt>提示：</dt>
        <dd>
            <a href="#">没有符合查询条件的查询结果，请更换查询条件重试！</a>
        </dd>
    
    <%} %>
    </form>
</dl>
<div class="pageWrap bottom">
    <div class="result">
          <input onclick="selectAll(true,'paperid');" type="button" value="全选" class="btn btn-primary"/>
            <input onclick="selectAll(false,'paperid');" type="button" value="清除" class="btn btn-primary"/>
            <input onclick="exportData();" type="button" value="导出" class="btn btn-primary"/>
        </div>
        <div class="page">
             <%=pageStr%>
        </div>
</div>
<!--/检索结果-->
</body>
</html>
 